import api from '../index'
import type { ResponseData } from '../index'
import type {TabbarPageItem} from '@/common/stores/init'

export type PageComponentsOption = {
	componentsName:'page',
	_componentsHidden:boolean
	headerColor:string,
	type: '0'|'1'|'2',
	backgroundColor: string,
	headerTextColor: string,
	styleType: '0'|'1',
	backgroundUrl: string,
	paddingTop: number,
	paddingBottom: number,
	paddingX: number,
	styleTextColor: string
}
export type ShareComponentsOption = {
	componentsName:'share',
	_componentsHidden:boolean
	title: string,
	imgUrl: string,
	type: '0'|'1',
	desc: string,
	mpType:'0'|'1',
	mpImgUrl:string
}
export type PopAdvertisingComponentsOption = {
	componentsName:'popAdvertising',
	_componentsHidden:boolean
	openAd: boolean,
	imgUrl: string,
	link?:{
		pageUrl:string,
		linkUrl:string,
		pageType:1|2|4
	},
	showType: 1|2//1、仅首次 2、多次,
	count: 1// showType为2时的显示次数,
}


// 预览模板信息
export type PageLayouts = Array<PageComponentsOption|ShareComponentsOption|PopAdvertisingComponentsOption|Record<string,any>&{componentsName:string,_componentsHidden:boolean}>
export const getPageInfo = (id:string|number) =>
	api.get<ResponseData<TabbarPageItem>>(`system/api/page/detail/${id}`,{
		custom:{
			auth:false
		}
	})
